#ifndef SOCKS5_ACTION_BIND_H
#define SOCKS5_ACTION_BIND_H
#pragma once

#include <KTimerQueue.h>
#include "S5Action.h"

class S5ActionClient;

class S5ActionBind : public S5Action, KTimer {
public:
    explicit S5ActionBind(S5ActionClient *client);
    ~S5ActionBind();
public:
    bool isProxy() const { return true; }
    void relay(const void *data, size_t length, const KIAddress *dest);
protected:
    void abortImp();
    void onAccepted(KSocket *client);
    void onClosing(bool stopped);
    void onError(KDef::SockError type, DWORD error);
    void onFatalError(KDef::SockError type, DWORD error);
    void onReceived(KKey *&key, void *data, size_t length, bool more);
    void onSent(KKey *&key, void *data, size_t length);
    void tick();
private:
    bool            m_listen;
    S5ActionClient *m_client;
};

#endif // SOCKS5_ACTION_BIND_H